package com.lagou.work02;

/**
 * 手机卡类
 */
public class Code03PhoneCard {

    private String cardType;
    private String cardId;
    private String userName;
    private String password;
    private int accountBalance;
    private int callDuration;
    private int networkData;
    private Code03UserConsume userConsume;

    public Code03PhoneCard() {
    }

    /**
     *
     * @param cardType 卡类型，枚举
     * @param cardId 电话号码
     * @param userName 用户名
     * @param password 密码
     * @param accountBalance 余额
     * @param callDuration 通话套餐分钟数
     * @param networkData 上网套餐流量
     * @param userConsume 消费统计对象
     */
    public Code03PhoneCard(String cardType, String cardId, String userName, String password, int accountBalance,
                             int callDuration, int networkData, Code03UserConsume userConsume) {
        setCardType(cardType);
        setCardId(cardId);
        setUserName(userName);
        setPassword(password);
        setAccountBalance(accountBalance);
        setCallDuration(callDuration);
        setNetworkData(networkData);
        setUserConsume(userConsume);
    }

    public String getCardType() {
        return cardType;
    }

    public void setCardType(String cardType) {
        this.cardType = cardType;
    }

    public String getCardId() {
        return cardId;
    }

    public void setCardId(String cardId) {
        this.cardId = cardId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int getAccountBalance() {
        return accountBalance;
    }

    public void setAccountBalance(int accountBalance) {
        this.accountBalance = accountBalance;
    }

    public int getCallDuration() {
        return callDuration;
    }

    public void setCallDuration(int callDuration) {
        this.callDuration = callDuration;
    }

    public int getNetworkData() {
        return networkData;
    }

    public void setNetworkData(int networkData) {
        this.networkData = networkData;
    }

    public Code03UserConsume getUserConsume() {
        return userConsume;
    }

    public void setUserConsume(Code03UserConsume userConsume) {
        this.userConsume = userConsume;
    }

    /**
     * 增加消费方法
     *
     * @param consumeValue 消费金额
     * @param consumeCallDuration 通话时长
     * @param consumeNetworkData 上网流量
     */
    public void addComsume(int consumeValue, int consumeCallDuration, int consumeNetworkData) {
        // 记录消费金额
        getUserConsume().setConsumeValue(getUserConsume().getConsumeValue() + consumeValue);
        // 记录通话时长
        getUserConsume().setConsumeCallDuration(getUserConsume().getConsumeCallDuration() + consumeCallDuration);
        //记录上网流量
        getUserConsume().setConsumeNetworkData(getUserConsume().getConsumeNetworkData() + consumeNetworkData);
    }

    //打印信息
    public void showInfo() {
        System.out.printf("卡号：%s\n用户名：%s\n当前余额：%d元\n", getCardId(), getUserName(), getAccountBalance());
        // 打印消费情况
        getUserConsume().showInfo();
    }

    /**
     * 多态
     * 打印用户所有信息与各类套餐内容
     * @param abstractPackage 套餐抽象类对象
     */
    public void showOnCreate(Code03AbstractPackage... abstractPackage) {
        System.out.printf("卡号：%s\n类型：%s\n用户名：%s\n密码：%s\n时长包：%d分钟\n流量包：%dGB\n当前余额：%d元\n", getCardId(), getCardType(),
                getUserName(), getPassword(), getCallDuration(), getNetworkData(), getAccountBalance());
        for (int i = 0; i < abstractPackage.length; i++) {
            abstractPackage[i].showInfo();
        }
    }
}
